﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint.Administration;

using SPaDevToolkit.Administration;

namespace Northwind.ServiceObjects
{
    public sealed class NorthwindServiceFactory : SPaWebServiceFactory<NorthwindService, NorthwindServiceProxy, NorthwindServiceInstance, NorthwindApplication, NorthwindApplicationProxy>
    {
        public NorthwindServiceFactory(SPWebService adminService) : base(adminService) { }

        public override NorthwindService CreateService()
        {
            NorthwindService service = new NorthwindService(AdminService.Farm);
            service.Update();
            service.Provision();
            return service;
        }

        public override NorthwindServiceProxy CreateServiceProxy(string name)
        {
            NorthwindServiceProxy serviceProxy = new NorthwindServiceProxy(NorthwindServiceProxy.DefaultName, AdminService.Farm);
            serviceProxy.Update();
            serviceProxy.Provision();
            return serviceProxy;
        }

        public override NorthwindServiceInstance CreateServiceInstance(string name, SPServer server, NorthwindService service)
        {
            NorthwindServiceInstance serviceInstance = new NorthwindServiceInstance(NorthwindServiceInstance.DefaultName, server, service);
            serviceInstance.Update();
            return serviceInstance;
        }
    }
}
